package com.jycrm.service.attachment.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.jycrm.dao.attachment.IAttTypeDao;
import com.jycrm.domain.attachment.CrmAttType;
import com.jycrm.service.attachment.IAttTypeService;
import com.jycrm.util.DataDictConstantValue;



public class AttTypeServiceImpl implements IAttTypeService{
	private IAttTypeDao attTypeDao;

	public IAttTypeDao getAttTypeDao() {
		return attTypeDao;
	}
	public void setAttTypeDao(IAttTypeDao attTypeDao) {
		this.attTypeDao = attTypeDao;
	}
	public CrmAttType findAttTypeById(Long id){
		return attTypeDao.findAttTypeById(id);
	}
	public List getAllAttTypeList() {
		return attTypeDao.getAllAttTypeList();
	}
	
	public List getAttTypeSelectionList() {
		List temp = getAllAttTypeList();
		List list = new ArrayList();
		if(list != null) {
        	Iterator it = temp.iterator();
            while(it.hasNext()){        
            	CrmAttType tmpData=(CrmAttType)it.next();
                String[][] value = new String[1][2];
                value[0][0] = tmpData.getId().toString();
                value[0][1] = tmpData.getName();
                list.add(value);
            }
        }
        return list;
	}
    
	public void saveAttType(CrmAttType attType){
		attTypeDao.saveAttType(attType);
	}
    public void cleanupAttType(CrmAttType attType){	
    	attType.setIsValid(DataDictConstantValue.DATADICT_GENERAL_NO_CODE);
        attTypeDao.updateAttType(attType); 
    }
    public void delAttType(CrmAttType attType){	
    	attTypeDao.delAttType(attType); 
    }
}

